{% extends "default.html" %}

{% block content %}
<div class="title">
	Repuesto - {{ request.itemtemplate.name }}
</div>
<div class="content">
	<div>Los art&iacute;culos que se tienen en Stock de este tipo son</div>
	<table id="itemtemplate_table">
		<tr>
			<th>Serial</th>
			<th>Precio de venta</th>
			<th>Ubicaci&oacute;n</th>
			<th>Obtenido por</th>
			<th>En Almac&eacute;n</th>
			{% if request.vendor.is_owner %}
				<th>Acciones</th>
			{% endif %}
		</tr>
		{% if request.items %}
			{% for item in request.items %}
			<tr>
				<td><a href="/item/{{ item.id }}/">{{ item.serial }}</a></th>
				<td>{{ item.sale_price }} {{ item.currency }}</td>
				<td>{{ item.location }}</th>
				<td>{{ item.obtainment }}</th>
				<td>{{ item.warehouse }}</th>
				{% if request.vendor.is_owner %}
					<td><a href="/item/delete/{{ item.id }}/{{ item.item_template.id }}/">Eliminar</a></td>
				{% endif %}
			</tr>
			{% endfor %}
		{% else %}
			<tr>
				<td colspan="2">
					No hay art&iacute;culos registrados de este tipo
				</td>
			</tr>
		{% endif %}
	</table>
	<div>Para registrar art&iacute;culos de este tipo ingrese la siguiente informaci&oacute;n</div>
	<form action="/itemtemplate/{{request.itemtemplate.id}}/register/" method="post">
		<table id="item_table_register">
			<tr>
				<th>Serial</th>
				<td><input type="text" name="serial" autocomplete='off'></td>
			</tr>
			<tr>
				<th>Ubicaci&oacute;n</th>
				<td><input type="text" name="location" autocomplete='off'></td>
			</tr>
			<tr>
				<th>Fecha de Vencimiento</th>
				<td><input type="text" name="expiration"></td>
			</tr>
			<tr>
				<th>Precio b&aacute;sico</th>
				<td><input type="text" name="basic_price"></td>
			</tr>
			<tr>
				<th>Precio de venta</th>
				<td><input type="text" name="sale_price"></td>
			</tr>
			<tr>
				<th>Moneda a utilizar</th>
				<td>
					{% if request.currencies %}
						<select name="currency">
						{% for c in request.currencies %}
						<option value="{{ c.id }}">{{ c.name }}</option>
						{% endfor %}
						</select>
					{% else %}
					No se ha configurado el estado monetario de la aplicaci&oacute;n<br>Para configurarla ingrese <a href="/currency/"	>aqu&iacute;</a>
					{% endif %}
				</td>
			</tr>
			<tr>
				<th>En stock por</th>
				<td>
					{% if  request.obtainments %}
					<select name="obtainment">
						{% for obtainment in request.obtainments %}
						<option value="{{ obtainment.id }}">{{ obtainment.comment }}</option>
						{% endfor %}
					</select>
					{% else %}
					No existen modos de obtener items<br>Para crear uno ingrese <a href="/obtainment/">aqu&iacute;</a>
					{% endif %}
				</td>
			</tr>
			<tr>
				<th>En almac&eacute;n</th>
				<td>
					{% if request.warehouses %}
						<select name="warehouse">
						{% for wh in request.warehouses %}
							<option value="{{ wh.id }}">{{ wh.name }}</option>
						{% endfor %}
						</select>
					{% else %}
					No existen almacenes registrados<br>Para registrar uno ingrese <a href="/warehouse/">aqu&iacute;</a>
					{% endif %}
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="submit" value="Registrar">
				</td>
			</tr>
		</table>
	</form>
</div>
{% endblock %}